package com.hxzy.source.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.hxzy.site.entity.TtSite;
import com.hxzy.site.mapper.TtSiteMapper;
import com.hxzy.site.service.TtSiteService;
import com.hxzy.source.entity.TtSourceList;
import com.hxzy.source.mapper.TtSourceListMapper;
import com.hxzy.source.service.TtSourceListService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.common.annotation.DataSource;
import com.ruoyi.common.enums.DataSourceType;
import com.sun.scenario.effect.impl.sw.sse.SSEBlend_SRC_OUTPeer;
import org.apache.poi.ss.formula.functions.T;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Objects;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author mingqian.Wu
 * @since 2023-06-26
 */
@Service
@DataSource(DataSourceType.SOURCE)
public class TtSourceListServiceImpl extends ServiceImpl<TtSourceListMapper, TtSourceList> implements TtSourceListService {

    @Autowired
    private TtSiteMapper ttSiteMapper;


    @Override
    public List<TtSourceList> searchSource(TtSourceList ttSourceList) {
        QueryWrapper<TtSourceList>queryWrapper=new QueryWrapper<>();
        queryWrapper.eq(Objects.nonNull(ttSourceList.getSourceId()),"source_id", ttSourceList.getSourceId());
        queryWrapper.like(Objects.nonNull(ttSourceList.getCompaniesName()),"companies_name",ttSourceList.getCompaniesName());
        queryWrapper.eq(Objects.nonNull(ttSourceList.getLoadingSiteId()),"loading_site_id",ttSourceList.getLoadingSiteId());
        queryWrapper.eq(Objects.nonNull(ttSourceList.getUnloadingSiteId()),"unloading_site_id",ttSourceList.getUnloadingSiteId());
        queryWrapper.eq(Objects.nonNull(ttSourceList.getSourceStatus()),"source_status",ttSourceList.getSourceStatus());
        List<TtSourceList> ttSourceLists = baseMapper.selectList(queryWrapper);
        return ttSourceLists;
    }

    @Override
    public TtSourceList getSourceById(String id) {
        TtSourceList ttSourceList = baseMapper.selectById(id);
        return ttSourceList;
    }


}
